<style>
    .form-signin {
        max-width: 330px;
        padding: 15px;
        margin: 0 auto;
    }
    .form-signin .form-signin-heading,
    .form-signin .checkbox {
        margin-bottom: 10px;
    }
    .form-signin .checkbox {
        font-weight: normal;
    }
    .form-signin .form-control {
        position: relative;
        height: auto;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        padding: 10px;
        font-size: 16px;
    }
    .form-signin .form-control:focus {
        z-index: 2;
    }
    .form-signin input[type="email"] {
        margin-bottom: -1px;
        border-bottom-right-radius: 0;
        border-bottom-left-radius: 0;
    }
    .form-signin input[type="password"] {
        margin-bottom: 10px;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }
</style>
<?php
$reqs = Blyn::app()->getActiveSpace()->getSpaceEngine()->getWXJoinSpaceRequests();
//$space = Blyn::app()->getActiveSpace();

/*
  if ($reqs != NULL) {
  foreach ($reqs as $reqId => $request) {
  $sender_user = new BUser($request['userId']);
  $sender_Space = new BSpace($request['spaceId']);
  $sender_sApp = Yii::t('site', BApp::getAppById($request['appId'])->name);
  $requestItem = array('messageId' => $reqId, 'roleId' => $request['roleId'], 'userId' => $request['userId']);
  }
  $model = new BDynamicFormModel();
  $roleField = 'media_roleId_membership';
  $model->addField($roleField);
  }
 * 
 */
?>

<div class="container">
    <?php
//if ($reqs != NULL) 
    $form = $this->beginWidget('CActiveForm', array(
        "id" => "manage-myInfo-form",
        'enableAjaxValidation' => FALSE,
        'htmlOptions' => array('class' => 'form-signin', 'role' => 'form'),
    ));
    ?>
    <legend>
        <h3 class="form-signin-heading text-muted">
            审批申请 | 
            <?php
            echo $control->getAjaxLink(
                    array('id' => BUIMembership::Show_Delete_Membership, 'name' => '管理会员')
            );
            ?>
        </h3>
    </legend>

    <div class="displayUserInfo">
        <?php
        if (isset($applyResult)) {
            if ($applyResult == 'rejected') {
                ?>
                <p class="bg-warning">
                    <strong>用户: <?php echo $userName; ?> 申请已拒绝.</strong>
                </p>
                <?php
            } else if ($applyResult == 'approved') {
                ?>
                <p class="bg-success">
                    <strong>用户: <?php echo $userName; ?> 申请已批准.</strong>
                </p>
                <?php
            }
        }
        ?>
    </div>
    <div class="displayUserInfo">
        <table class="table table-striped">
            <tbody>
                <?php
                if ($reqs == NULL)
                    echo "暂无成员申请.";
                else {
                    foreach ($reqs as $reqId => $request) {
                        $model = new BDynamicFormModel();
                        $roleField = 'media_roleId_membership';
                        $model->addField($roleField);
                        $sender_user = new BUser($request['userId']);
                        $sender_Space = new BSpace($request['spaceId']);
                        $sender_sApp = Yii::t('site', BApp::getAppById($request['appId'])->name);
                        $requestItem = array('messageId' => $reqId, 'roleId' => $request['roleId'], 'userId' => $request['userId']);
                        ?>
                        <tr>
                            <td>申请用户</td>
                            <td><?php echo $sender_user->getName(); ?></td></tr>
                        <tr>
                            <td>申请角色</td>
                            <td><?php echo Yii::t('site', $request['applyingRole']); ?></td>
                        </tr>
                        <tr>
                            <td><?php
                                echo $control->getAjaxLink(array('name' => '批准申请', 'id' => BUIMembership::Approve_Apply), array(
                                    'reqId' => $requestItem,
                                    'messageId' => $reqId,
                                    'roleId' => $request['roleId'],
                                    'userId' => $request['userId'],
                                    'htmlOptions' => array(
                                        'class' => 'btn btn-success btn-block'
                                )));
                                ?>
                            </td>
                            <td><?php
                                echo $control->getAjaxLink(array('name' => '拒绝申请', 'id' => BUIMembership::Reject_Apply), array('reqId' => $requestItem, 
                                    'reqId' => $requestItem,
                                    'messageId' => $reqId,
                                    'roleId' => $request['roleId'],
                                    'userId' => $request['userId'],
                                    'htmlOptions' => array(
                                        'class' => 'btn btn-warning btn-block'
                                )));
                                ?>
                            </td>
                        </tr>
                        <tr><td style="padding-top: 10px"></td><td></td></tr>
                                <?php
                            }
                        }
                        ?>
            </tbody>
        </table>
    </div>
    <?php
    //if ($reqs != NULL) 
    $this->endWidget();
    ?>
</div>
